#include <N76E003.h>
#include <platform/gpio.h>

void uart_init(u32 baud_rate)
{
	gpio_set_mode(0, 6, IN_OUT);
	gpio_set_mode(0, 7, IN_OUT);
	SCON = 0x52;
	TMOD |= 0x20;
	set_bit(PCON, 7);
	set_bit(CKCON, 4);
	clr_bit(T3CON, 5);
	TH1 = 256 - (1000000 / baud_rate + 1);
	TR1 = 1;
}

void uart_send_byte(u8 c)
{
    TI = 0;
    SBUF = c;
    while(TI == 0);
}

/*
u8 uart_recv_byte(void)
{
    u8 c;
    
    while (!RI);
    c = SBUF;
    RI = 0;
    return (c);
}
*/
